/*
 * @Description: Router of controllers
 * @Author: Jinzhu Liu
 * @Date: 2021-11-24 18:05:09
 * @LastEditor: Jinzhu Liu
 * @LastEditTime: 2021-12-26 23:45:55
 */

import koaRouter from 'koa-router'
import AdminController from '../controller/admin_controller'
import IndexController from '../controller/index_controller'
import LoginController from '../controller/login_controller'
import MyWatchlistController from '../controller/my_watchlist_controller'
import ResourceController from '../controller/resource_controller'
import UploadController from '../controller/upload_controller'
import AuthMiddleware from '../middleware/auth_middleware'

const router = new koaRouter({ prefix: '/' })

router.get('resource/:name', ResourceController.index)
router.get('my-watchlist', MyWatchlistController.index)

router.get('admin/list', AdminController.getAdminList)
router.post('admin/add', AdminController.addAdmin)
router.put('admin/update/:id', AdminController.updateAdmin)
router.delete('admin/delete/:id', AdminController.deleteAdmin)
router.post('admin/login', LoginController.index)

router.post('upload', UploadController.upload)
router.use(AuthMiddleware)
router.get('admin', IndexController.index)

export default router